setwd("~/Dropbox/LGBT/data")

library(foreign)
library(xtable)
library(reporttools)

rm(list=ls())
Allmiss <- read.dta("output/ALLmis.dta")

############################################
# Descriptive Stats table
############################################
attach(Allmiss)
names(Allmiss)


vars = c("legit", "polity2", "Politcomp", "presidential", "malecrime", 
         "hdi", "aids", "wb_gdppc","aidcommit_pc", "lpopulation", "popdensity", 
         "christian_mjr", "renwshare_pop", "christians_share", "muslims_share")
fitsHigh <- matrix(NA, nrow=length(vars), ncol=4)
tpHigh<- matrix(NA, nrow=length(vars), ncol=1)

for(v in 1:length(vars)) {
  U=Allmiss[,vars[v]]
  tpHigh[v,] = t.test(U~ALLmis)$p.value
  fitsHigh[v,]=cbind(mean(U[ALLmis==0], na.rm=T), mean(U[ALLmis==1], na.rm=T), 
              mean(U[ALLmis==1],na.rm=T)-mean(U[ALLmis==0],na.rm=T), tpHigh[v,]) 
}       
           
colnames(fitsHigh) <- c("In dataset", "No Data", "Diff", "p.value")
rownames(fitsHigh) <- c("State legitimacy", "Polity IV index", "Minority seat share", "Presidential", 
                        "Homosexuality criminal", "Human Development Index", "HIV prevalence", 
                        "GDP per capita", "Aid committed per capita", "Population (log)", "Population desnity", 
                        "Christian majority", "Renewalists share", "Christians population share", "Muslims population share")
print(fitsHigh)

xtable(fitsHigh, digits=3)
